home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / ARCHIVES.SWG / 0012_Zip File Viewer.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  5KB  |  173 lines

  1. {
  2. Author: Steve Wierenga
  3. ZIP Viewer
  4. }
  5.  
  6. Unit ZipV;
  7.  
  8. (**) Interface (**)
  9.  
  10. Uses
  11.   Dos,Crt;
  12. Procedure ZipView(ZIPFile:String);
  13. Function GAN(ZIPFile : String) : String;
  14.  
  15. (**) Implementation (**)
  16.  
  17. Procedure Terminate;
  18. begin
  19.   Write('ARCHPEEK could not find specified File. Aborting...');
  20.   Halt;
  21. end;
  22.  
  23. Procedure ZipView(ZIPFile : String);  { View the ZIP File }
  24. Const
  25.   SIG = $04034B50;                  { Signature }
  26. Type
  27.   ZFHeader = Record                 { Zip File Header }
  28.     Signature  : LongInt;
  29.     Version,
  30.     GPBFlag,
  31.     Compress,
  32.     Date,Time  : Word;
  33.     CRC32,
  34.     CSize,
  35.     USize      : LongInt;
  36.     FNameLen,
  37.     ExtraField : Word;
  38.   end;
  39.  
  40. Var
  41.   z       : Integer;
  42.   x,
  43.   totalu,
  44.   totalc  : LongInt;
  45.   Hdr     : ^ZFHeader;
  46.   F       : File;
  47.   S,sss   : String;
  48.   own     : Text;
  49.   dt1     : DateTime;
  50.   l       : String[80];
  51.   registered : Boolean;  { Is registered? }
  52.  
  53. Const
  54.   CompTypes : Array[0..7] of String[9] =
  55.               ('Stored ','Shrunk   ','Reduced1','Reduced2','Reduced3',
  56.                'Reduced4','Imploded ','Deflated');
  57.   { Method used to compress }
  58.   r = #196;
  59.   q = #205;
  60.  
  61. begin
  62.   z := 0; totalu := 0; totalc := 0; { Init Variables }
  63.   registered := False; { Unregistered }
  64.   if not registered then   { Is registered? }
  65.   begin
  66.     Writeln('ArchPeek 0.01Alpha [UNREGISTERED] Copyright 1993 Steve Wierenga');
  67.     Delay(200);
  68.   end;
  69.   New(Hdr);
  70.   Assign(F,ZIPFile);
  71.   {$I-}
  72.   Reset(F,1);                   { Open File }
  73.   {$I+}
  74.   If IOResult <> 0 then Terminate;  { Couldn't open Zip File }
  75.   sss := GAN(ZipFile);              { Get the Zip Filename }
  76.   Writeln('Zip FileName: ',sss);
  77.   WriteLn( '   Name           Length      Size  Saved Method');
  78.   WriteLn(r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,
  79.           r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r);
  80.   Repeat
  81.     FillChar(S,SizeOf(S), #0);  { Pad With nulls }
  82.     BlockRead(F,Hdr^,SizeOf(ZFHeader));
  83.     { Read File Header }
  84.     BlockRead(F,Mem[Seg(S) : Ofs(S) + 1], Hdr^.FNameLen);
  85.     s[0] := Chr(Hdr^.FNameLen);
  86.     Case Length(S) Of    { Straighten String }
  87.      0  : s := s + '            ';
  88.      1  : S := s + '           ';
  89.      2  : s := s + '          ';
  90.      3  : S := S + '         ';
  91.      4  : S := S + '        ';
  92.      5  : S := S + '       ';
  93.      6  : S := S + '      ';
  94.      7  : S := S + '     ';
  95.      8  : S := S + '    ';
  96.      9  : S := S + '   ';
  97.      10 : S := S + '  ';
  98.      11 : S := S + ' ';
  99.      12 : S := S;
  100.     end;
  101.       If (Hdr^.Signature = Sig) Then { Is a header }
  102.     begin
  103.       z := z + 1;
  104.       WriteLn(S,Hdr^.USize:9,Hdr^.CSize:10,(100-Hdr^.CSize/Hdr^.USize*100):5:0,'%',
  105.               CompTypes[Hdr^.Compress]:16);
  106.       Inc(TotalU,Hdr^.USize);  { Increment size uncompressed }
  107.       Inc(TotalC,Hdr^.CSize);  { Increment size compressed }
  108.     end;
  109.     Seek(F,FilePos(F) + Hdr^.CSize + Hdr^.ExtraField);
  110.   Until Hdr^.Signature <> SIG; { No more Files }
  111.   GetFTime(F,x);
  112.   UnPackTime(x,DT1);
  113.   WriteLn(q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,
  114.           q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q);
  115.   Write( z:4,' Files ',TotalU:12,TotalC:10,(100-TotalC/TotalU*100):5:0,'%');
  116.   Case dt1.month of        { Get Zip File date and time }
  117.     1..9   : Write( '0':4,dt1.month);
  118.     10..12 : Write( dt1.month:4);
  119.   end;
  120.   Write( '/');
  121.   Case dt1.day of
  122.     1..9   : Write( '0',dt1.day);
  123.     10..31 : Write( dt1.day);
  124.   end;
  125.   Write( '/');
  126.   Case dt1.year of
  127.     1980 : Write( '80');
  128.     1981 : Write( '81');
  129.     1982 : Write( '82');
  130.     1983 : Write( '83');
  131.     1984 : Write( '84');
  132.     1985 : Write( '85');
  133.     1986 : Write( '86');
  134.     1987 : Write( '87');
  135.     1988 : Write( '88');
  136.     1989 : Write( '89');
  137.     1990 : Write( '90');
  138.     1991 : Write( '91');
  139.     1992 : Write( '92');
  140.     1993 : Write( '93');
  141.     1994 : Write( '94');
  142.     1995 : Write( '95');
  143.     1996 : Write( '96');
  144.   end;
  145.   Case dt1.hour of
  146.     0..9   : Write( '0':3,dt1.hour,':');
  147.     10..23 : Write( dt1.hour:3,':');
  148.   end;
  149.   Case dt1.min of
  150.     0..9   : Write( '0',dt1.min,':');
  151.     10..59 : Write( dt1.min,':');
  152.   end;
  153.   Case dt1.sec of
  154.     0..9   : Writeln( '0',dt1.sec);
  155.     10..59 : Writeln( dt1.sec);
  156.   end;
  157.   Close(F);
  158.   Dispose(Hdr);
  159. end;
  160.  
  161.  
  162. Function GAN(ZIPFile:String): String;
  163. Var
  164.   Dir  : DirStr;
  165.   Name : NameStr;
  166.   Exts : ExtStr;
  167. begin
  168.   FSplit(ZIPFile,Dir,Name,Exts);
  169.   GAN := Name + Exts;
  170. end;
  171.  
  172. end.
  173.